<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <link rel="stylesheet" href="/static/css/index.css">
</head>
<body>
<div class="container">
    <div class="sidebar">
        <a href="#" class="active">用户管理</a>
        <a href="/booklist">图书管理</a>
    </div>
    <div class="main-content">
        <div style="text-align: center">
            <span style="color: darkslategray; font-size: 20px"><h1>基于springboot的书籍管理平台</h1></span>
            <p><span style="color: #800080" th:text="${#session.getAttribute('name')}"></span> , 欢迎你！</p>
            <p>你的身份是：<span style="color: #ff0000" th:text="${#session.getAttribute('userrole')}"></span></p>
            <div>
                <form action="/list">
                    <input type="text" name="uname" th:value="${uname}" placeholder="请输入用户名"/>
                    <input type="submit" value="查询"/>
                </form>
            </div>
            <br>
            <table class="list">
                <tr>
                    <th>编号</th>
                    <th>用户</th>
                    <th>密码</th>
                    <th>用户类型</th>
                    <th>操作</th>
                </tr>
                <tr th:each="user : ${pageInfo.getList()}">
                    <td th:text="${user.id}">0</td>
                    <td th:text="${user.username}">张三</td>
                    <td th:text="${user.password}">zhangsan</td>
                    <td th:text="${user.roles.roleName}">用户类型</td>
                    <td>
                        <a th:href="@{'/updatePage/'+${user.id}}">更改</a>
                        <a th:href="@{'/delete/'+${user.id}}">删除</a>
                    </td>
                </tr>
            </table>
            <!--分页的前端-->
            <div style="text-align: center;margin-top:20px">
                当前第<span th:text="${pageInfo.pageNum}"></span>页，共<span th:text="${pageInfo.total}"></span>条记录，共<span th:text="${pageInfo.pages}"></span>页
                <a th:if="${pageInfo.pageNum==1}" href="javascript:void(0)">上一页</a>
                <a th:if="${pageInfo.pageNum!=1}" th:href="@{/list(uname=${uname},pageNum=${pageInfo.pageNum}-1)}">上一页</a>
                <a th:each="i:${#numbers.sequence(1,pageInfo.pages)}">
                    <a th:href="@{/list(uname=${uname},pageNum=${i})}" th:text="${i}"></a>
                </a>
                <a th:if="${pageInfo.pageNum}==${pageInfo.pages}" href="javascript:void(0)">下一页</a>
                <a th:if="${pageInfo.pageNum}!=${pageInfo.pages}" th:href="@{/list(uname=${uname},pageNum=${pageInfo.pageNum}+1)}">下一页</a>
            </div>

            <button><a href="/useradd" style="font-size: 15px">添加用户</a></button>
            <br>
            <a href="/login">退出系统</a>
        </div>
    </div>
</div>
</body>
</html>